RTrack Analysis

Jonas Wagner

2021-06-03


Importing Data

Here a multicore CPU cluster is opened to reduce experiment reading times. This cluster is closed after the execution of the code.

cluster = parallel::makeCluster(rep("localhost", parallel::detectCores()), type = "SOCK")
experiment = Rtrack::read_experiment("Experiment_description2.xlsx", format = "Excel", cluster = cluster) 
parallel::stopCluster(cluster)

Analysis of experiment metrics

These metrics can be compared and extracted from the pure track files.

experiment$summary.variables
 [1] "path.length"                    "mean.velocity"                 
 [3] "sd.velocity"                    "total.time"                    
 [5] "latency.to.goal"                "goal.crossings"                
 [7] "old.goal.crossings"             "coverage"                      
 [9] "mean.d.centroid"                "mean.d.goal"                   
[11] "mean.d.old.goal"                "mean.d.origin"                 
[13] "sd.d.centroid"                  "sd.d.goal"                     
[15] "sd.d.old.goal"                  "sd.d.origin"                   
[17] "centroid.goal.displacement"     "centroid.old.goal.displacement"
[19] "mean.initial.heading.error"     "initial.trajectory.error"      
[21] "initial.reversal.error"         "turning"                       
[23] "turning.absolute"               "efficiency"                    
[25] "roaming.entropy"                "time.in.zone.pool"             
[27] "time.in.zone.wall"              "time.in.zone.far.wall"         
[29] "time.in.zone.annulus"           "time.in.zone.goal"             
[31] "time.in.zone.old.goal"          "time.in.zone.n.quadrant"       
[33] "time.in.zone.e.quadrant"        "time.in.zone.s.quadrant"       
[35] "time.in.zone.w.quadrant"       

back to top

par(mfrow = c(2, 2))
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Strain", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Age_group", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Housing", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "All", exclude.probe = TRUE,lwd = 2)

Note that the probe trials have been omitted from these plots.

back to top


Heatmap

wt.metrics = experiment$metrics[experiment$factors$Strain == "WT" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4|
experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
dTg.metrics = experiment$metrics[experiment$factors$Strain == "dTg" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
APP.metrics = experiment$metrics[experiment$factors$Strain == "APPswe" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
PS1.metrics = experiment$metrics[experiment$factors$Strain == "PS1dE9" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
par(mfrow = c(2, 2))
Rtrack::plot_density(wt.metrics, title = "wt Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTg.metrics, title = "dTg Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APP.metrics, title = "APPswe Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1.metrics, title = "PS1dE9 Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

back to top


Heatmap_reversal

wtr.metrics = experiment$metrics[experiment$factors$Strain == "WT" &
                                           (experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
dTgr.metrics = experiment$metrics[experiment$factors$Strain == "dTg" &
                                            (experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
APPr.metrics = experiment$metrics[experiment$factors$Strain == "APPswe" &
                                  (experiment$factors$`_Day` ==7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
PS1r.metrics = experiment$metrics[experiment$factors$Strain == "PS1dE9" &
                                   (experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
par(mfrow = c(2, 2))
Rtrack::plot_density(wtr.metrics, title = "WT_reversal Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgr.metrics, title = "dTg_reversal Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPr.metrics, title = "APPswe_reversal Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1r.metrics, title = "PS1dE9_reversal Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

back to top


Calling strategies

strategies = Rtrack::call_strategy(experiment$metrics)

Thresholding strategies

limits called strategies to those, where confidence is greater than 40%

dim(Rtrack::threshold_strategies(strategies, 0.4)$calls)
[1] 4203   12

back to top


Plotting strategies of all age groups combined

par(mfrow = c(2, 2))
Rtrack::plot_strategies(strategies, experiment = experiment, factor = "Strain",
    exclude.probe = TRUE)

back to top


Plotting thresholded strategies of all age groups combined

par(mfrow = c(2, 2))
Rtrack::plot_strategies(Rtrack::threshold_strategies(strategies, 0.4), experiment = experiment,
                        factor = "Strain", exclude.probe = TRUE)

back to top


Saving the results

Here we export the results of the analyzed Track Files into a data.frame, to analyse them further.

results = Rtrack::export_results(experiment)
datatable(results, rownames = FALSE, filter="top", options = list(pageLength = 5, scrollX=T) )

back to top


Plotting with ggplot2

library(ggplot2)
library(readxl)
Results=read_excel("Results3.xlsx", col_types=c("text","text","text","text","text","text","logical","numeric","text","text","text","numeric","text","numeric","text","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric"))
ggplot(Results, aes(x=`_Day`,y=path.length,color=factor(Strain)))+geom_jitter()

Results
# A tibble: 5,960 x 60
   Track_ID `_TargetID` `_Day` `_Trial` `_Arena`    Condition Probe Trial Strain
   <chr>    <chr>       <chr>  <chr>    <chr>       <chr>     <lgl> <dbl> <chr> 
 1 Track_4  60-911      1      1        Arena_SW.t~ WT_STD    FALSE     4 WT    
 2 Track_8  60-293      1      1        Arena_SW.t~ WT_STD    FALSE     8 WT    
 3 Track_9  60-296      1      1        Arena_SW.t~ WT_STD    FALSE     9 WT    
 4 Track_10 60-333      1      1        Arena_SW.t~ dTg_STD   FALSE    10 dTg   
 5 Track_14 60-911      1      2        Arena_SW.t~ WT_STD    FALSE    14 WT    
 6 Track_18 60-293      1      2        Arena_SW.t~ WT_STD    FALSE    18 WT    
 7 Track_19 60-296      1      2        Arena_SW.t~ WT_STD    FALSE    19 WT    
 8 Track_20 60-333      1      2        Arena_SW.t~ dTg_STD   FALSE    20 dTg   
 9 Track_24 60-911      1      3        Arena_SW.t~ WT_STD    FALSE    24 WT    
10 Track_28 60-293      1      3        Arena_SW.t~ WT_STD    FALSE    28 WT    
# ... with 5,950 more rows, and 51 more variables: Housing <chr>,
#   Age_group <chr>, Age_months <dbl>, All <chr>, strategy <dbl>, name <chr>,
#   confidence <dbl>, 1 <dbl>, 2 <dbl>, 3 <dbl>, 4 <dbl>, 5 <dbl>, 6 <dbl>,
#   7 <dbl>, 8 <dbl>, 9 <dbl>, path.length <dbl>, mean.velocity <dbl>,
#   sd.velocity <dbl>, total.time <dbl>, latency.to.goal <dbl>,
#   goal.crossings <dbl>, old.goal.crossings <dbl>, coverage <dbl>,
#   mean.d.centroid <dbl>, mean.d.goal <dbl>, mean.d.old.goal <dbl>,
#   mean.d.origin <dbl>, sd.d.centroid <dbl>, sd.d.goal <dbl>,
#   sd.d.old.goal <dbl>, sd.d.origin <dbl>, centroid.goal.displacement <dbl>,
#   centroid.old.goal.displacement <dbl>, mean.initial.heading.error <dbl>,
#   initial.trajectory.error <dbl>, initial.reversal.error <dbl>,
#   turning <dbl>, turning.absolute <dbl>, efficiency <dbl>,
#   roaming.entropy <dbl>, time.in.zone.pool <dbl>, time.in.zone.wall <dbl>,
#   time.in.zone.far.wall <dbl>, time.in.zone.annulus <dbl>,
#   time.in.zone.goal <dbl>, time.in.zone.old.goal <dbl>,
#   time.in.zone.n.quadrant <dbl>, time.in.zone.e.quadrant <dbl>,
#   time.in.zone.s.quadrant <dbl>, time.in.zone.w.quadrant <dbl>

back to top

CAREFUL!!! The graphs below still include the probe trials (day 7 trial 1). To remove them add: Probe==‘FALSE’ to filter


Path Length Graphs

WT_STD=filter(Results, Strain=='WT'&Housing=='STD')
dTg_STD=filter(Results, Strain=='dTg'&Housing=='STD')
APP_STD=filter(Results, Strain=='APPswe'&Housing=='STD')
PS_STD=filter(Results, Strain=='PS1dE9'&Housing=='STD')
WT_ENR=filter(Results, Strain=='WT'&Housing=='ENR')
dTg_ENR=filter(Results, Strain=='dTg'&Housing=='ENR')
APP_ENR=filter(Results, Strain=='APPswe'&Housing=='ENR')
PS_ENR=filter(Results, Strain=='PS1dE9'&Housing=='ENR')
par(mfrow = c(2, 4))

WT_STD %>%
  mutate(WT_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
  ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
    labs(x="Day",
       y="Average Path length",
       title="Mean Path length WT STD")+scale_fill_jco()

dTg_STD  %>%
mutate(dTg_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length dTg STD")+scale_fill_jco()

APP_STD  %>%
mutate(APP_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length APPswe1 STD")+scale_fill_jco()

PS_STD  %>%
mutate(PS_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length PS1dE9 STD")+scale_fill_jco()

WT_ENR  %>%
mutate(WT_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length WT ENR")+scale_fill_jco()

dTg_ENR  %>%
mutate(dTg_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length dTg ENR")+scale_fill_jco()

APP_ENR  %>%
mutate(APP_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length APPswe1 ENR")+scale_fill_jco()

PS_ENR  %>%
mutate(PS_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length PS1dE9 ENR")+scale_fill_jco()+
  facet_wrap(~Age_group)

back to top


Latency Graphs

WT_STD %>%
  mutate(WT_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
  ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
    labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s WT STD")+scale_fill_jco()

dTg_STD  %>%
mutate(dTg_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s dTg STD")+scale_fill_jco()

APP_STD  %>%
mutate(APP_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s APPswe1 STD")+scale_fill_jco()

PS_STD  %>%
mutate(PS_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s PS1dE9 STD")+scale_fill_jco()

WT_ENR  %>%
mutate(WT_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s WT ENR")+scale_fill_jco()

dTg_ENR  %>%
mutate(dTg_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s dTg ENR")+scale_fill_jco()

APP_ENR  %>%
mutate(APP_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s APPswe1 ENR")+scale_fill_jco()

PS_ENR  %>%
mutate(PS_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s PS1dE9 ENR")+scale_fill_jco()+
  facet_wrap(~Age_group)

back to top


UPDATED Heatmap_probe

par(mfrow = c(2, 2))
Rtrack::plot_density(wtp.metrics, title = "WT Probe Heatmap 3-25mo",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgp.metrics, title = "dTg Probe Heatmap 3-25mo",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPp.metrics, title = "APPswe Probe Heatmap 3-25mo",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1p.metrics, title = "PS1dE9 Probe Heatmap 3-25mo",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

par(mfrow = c(2, 4))
Rtrack::plot_density(wtpstd.metrics, title = "WT Probe Heatmap STD 3-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd.metrics, title = "dTg Probe Heatmap STD 3-25mo",    col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpstd.metrics, title = "APPswe Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1pstd.metrics, title = "PS1dE9 Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr.metrics, title = "WT Probe Heatmap ENR 3-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr.metrics, title = "dTg Probe Heatmap ENR 3-25mo",    col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr.metrics, title = "APPswe Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1penr.metrics, title = "PS1dE9 Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

WT -> dTg -> APPswe -> PS1dE9

back to top

par(mfrow = c(1, 3))
###########WT_Probe##########
Rtrack::plot_density(wtpstd3.metrics, title = "WT Probe Heatmap STD 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpstd14.metrics, title = "WT Probe Heatmap STD 13-14mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpstd25.metrics, title = "WT Probe Heatmap STD 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

Rtrack::plot_density(wtpenr3.metrics, title = "WT Probe Heatmap ENR 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr14.metrics, title = "WT Probe Heatmap ENR 13-14mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr25.metrics, title = "WT Probe Heatmap ENR 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

###########dTg_Probe##########
Rtrack::plot_density(dTgpstd3.metrics, title = "dTg Probe Heatmap STD 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd14.metrics, title = "dTg Probe Heatmap STD 13-14mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd25.metrics, title = "dTg Probe Heatmap STD 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

Rtrack::plot_density(dTgpenr3.metrics, title = "dTg Probe Heatmap ENR 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr14.metrics, title = "dTg Probe Heatmap ENR 13-14mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr25.metrics, title = "dTg Probe Heatmap ENR 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

###########APP_Probe##########
Rtrack::plot_density(APPpstd3.metrics, title = "APPswe Probe Heatmap STD 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(APPpstd14.metrics, title = "APPswe Probe Heatmap STD 13-14mo",
#  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpstd25.metrics, title = "APPswe Probe Heatmap STD 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr3.metrics, title = "APPswe Probe Heatmap ENR 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

#Rtrack::plot_density(APPpenr14.metrics, title = "APPswe Probe Heatmap ENR 13-14mo",
#  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr25.metrics, title = "APPswe Probe Heatmap ENR 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
###########PS1_Probe##########
Rtrack::plot_density(PS1pstd3.metrics, title = "PS1dE9 Probe Heatmap STD 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(PS1pstd14.metrics, title = "PS1dE9 Probe Heatmap STD 13-14mo",
#  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1pstd25.metrics, title = "PS1dE9 Probe Heatmap STD 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

Rtrack::plot_density(PS1penr3.metrics, title = "PS1dE9 Probe Heatmap ENR 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(PS1penr14.metrics, title = "PS1dE9 Probe Heatmap ENR 13-14mo",
#  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1penr25.metrics, title = "PS1dE9 Probe Heatmap ENR 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

back to top


UPDATED Path Length Graphs

mo3=filter(Results, Age_group=='3')
mo14=filter(Results, Age_group=='13-14')
mo25=filter(Results, Age_group=='17-25')

mo3 %>%
  mutate(mo3, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
  ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
    labs(x="Day",
       y="Average Path length",
       title="Mean Path length 3mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))

mo14  %>%
mutate(mo14, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length 13-14mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))

mo25  %>%
mutate(mo25, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length 17-25mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#6c7ed7", "dTg_STD" = "#909ef3","WT_ENR" = "#9f48a3", "WT_STD" = "#ce73cf","APPswe_ENR" = "#c85632", "APPswe_STD" = "#e9724b","PS1dE9_ENR" = "#9f9201", "PS1dE9_STD" = "#cab95b"))

back to top

Boxplot explanation:
Middle line in box -> Median
Box -> shows middle 50% of data(Distance between 1. and 3. Quartil)
Whisker(vertikal lines) -> show upper/lower 25% of data w/o outliers
Points -> outlier


UPDATED Velocity (Mean) Graphs

mo3=filter(Results, Age_group=='3')
mo14=filter(Results, Age_group=='13-14')
mo25=filter(Results, Age_group=='17-25')

mo3 %>%
  mutate(mo3, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
  ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
    labs(x="Day",
       y="Average Velocity",
       title="Mean Velocity 3mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))

mo14  %>%
mutate(mo14, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
  labs(x="Day",
       y="Average Velocity",
       title="Mean Velocity 13-14mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))

mo25  %>%
mutate(mo25, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
  labs(x="Day",
       y="Average Velocity",
       title="Mean Velocity 17-25mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#6c7ed7", "dTg_STD" = "#909ef3","WT_ENR" = "#9f48a3", "WT_STD" = "#ce73cf","APPswe_ENR" = "#c85632", "APPswe_STD" = "#e9724b","PS1dE9_ENR" = "#9f9201", "PS1dE9_STD" = "#cab95b"))

back to top


UPDATED Strategy (Thresholded) Graphs

par(mfrow = c(2, 2))
Rtrack::plot_strategies(Rtrack::threshold_strategies(strategies, 0.4), experiment = experiment,
                        factor = "All", exclude.probe = TRUE)

back to top


Probe Trial Number of Goals Crossings

mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Number of Goal Crossings",
       title="Probe Trial Number of Goal Crossings 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo14.probe  %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
  labs(x="Condition",
       y="Number of Goal Crossings",
       title="Probe Trial Number of Goal Crossings 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo25.probe  %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
  labs(x="Condition",
       y="Number of Goal Crossings",
       title="Probe Trial Number of Goal Crossings 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

back to top


Probe Trial Number of former Goals Crossings

mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Number of old Goal Crossings",
       title="Probe Trial Number of former Goal Crossings 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo14.probe  %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Number of old Goal Crossings",
       title="Probe Trial Number of former Goal Crossings 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo25.probe  %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Number of Old Goal Crossings",
       title="Probe Trial Number of former Goal Crossings 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

back to top


Probe Trial Time in old goal zone

mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=time.in.zone.old.goal, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Time in s",
       title="Probe Trial Time spent in old goal 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo14.probe  %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Time in s",
       title="Probe Trial Time spent in old goal 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo25.probe  %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Time in s",
       title="Probe Trial Time spent in old goal 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

back to top


Probe Trial Mean Initial heading error

mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Initial heading error in %??",
       title="Probe Trial Mean Initial heading error 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo14.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Initial heading error in %??",
       title="Probe Trial Mean Initial heading error 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo25.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Initial heading error in ???",
       title="Probe Trial Mean Initial heading error 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

back to top

Testing Layout Options


3 Months

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Initial heading error in %??",
       title="Probe Trial Mean Initial heading error 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

13-14 Months

mo14.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Initial heading error in %??",
       title="Probe Trial Mean Initial heading error 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

17-25 Months

mo25.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Initial heading error in ???",
       title="Probe Trial Mean Initial heading error 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

back to top

Probe Trial Mean Distance old goal


3 Months

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Distance",
       title="Probe Trial Mean Distance old goal 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

13-14 Months

mo14.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Distance",
       title="Probe Trial Mean Distance old goal 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

17-25 Months

mo25.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Distance",
       title="Probe Trial Mean Distance old goal 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

Arena Quadrant Problem


back to top

knitr::include_graphics("Watermaze_Setup.png")

In Ethovision those Quadrants are marked (NE, SE, SW, NW).
In contrast to that, the quadrants that can be analyzed with RTrack are called as below:
“time.in.zone.n.quadrant”
“time.in.zone.e.quadrant”
“time.in.zone.s.quadrant”
“time.in.zone.w.quadrant”

knitr::include_graphics("Watermaze_Quadrant.png")

t-Tests (time in old goal zone of probe trials) between Age Groups


3 / 13-14

t.test(mo3.probe$time.in.zone.old.goal,mo14.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  mo3.probe$time.in.zone.old.goal and mo14.probe$time.in.zone.old.goal
t = 0.41802, df = 55.572, p-value = 0.6775
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.4742248  0.7242732
sample estimates:
mean of x mean of y 
 1.248872  1.123847 

3 / 17-25

t.test(mo3.probe$time.in.zone.old.goal,mo25.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  mo3.probe$time.in.zone.old.goal and mo25.probe$time.in.zone.old.goal
t = -0.76178, df = 53.252, p-value = 0.4496
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.8365670  0.3759891
sample estimates:
mean of x mean of y 
 1.248872  1.479161 

13-14 / 17-25

t.test(mo14.probe$time.in.zone.old.goal,mo25.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  mo14.probe$time.in.zone.old.goal and mo25.probe$time.in.zone.old.goal
t = -0.96822, df = 62.942, p-value = 0.3366
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -1.0886658  0.3780395
sample estimates:
mean of x mean of y 
 1.123847  1.479161 

no significance between the overall groups


t-Tests (time in old goal zone of probe trials) between Strains & Housings of Age Group 17-25


17-25 WT STD/ENR

WTS.mo25.probe=filter(mo25.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo25.probe=filter(mo25.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo25.probe$time.in.zone.old.goal,WTE.mo25.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  WTS.mo25.probe$time.in.zone.old.goal and WTE.mo25.probe$time.in.zone.old.goal
t = 1.2667, df = 15.225, p-value = 0.2243
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.5876549  2.3148994
sample estimates:
mean of x mean of y 
 2.196897  1.333275 

13-14 WT STD/ENR

WTS.mo14.probe=filter(mo14.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo14.probe=filter(mo14.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo14.probe$time.in.zone.old.goal,WTE.mo14.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  WTS.mo14.probe$time.in.zone.old.goal and WTE.mo14.probe$time.in.zone.old.goal
t = -0.4615, df = 11.792, p-value = 0.6528
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2.172106  1.414007
sample estimates:
mean of x mean of y 
 1.278296  1.657345 

3 WT STD/ENR

WTS.mo3.probe=filter(mo3.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo3.probe=filter(mo3.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo3.probe$time.in.zone.old.goal,WTE.mo3.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  WTS.mo3.probe$time.in.zone.old.goal and WTE.mo3.probe$time.in.zone.old.goal
t = 0.86513, df = 16.892, p-value = 0.3991
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.8315724  1.9866145
sample estimates:
mean of x mean of y 
 1.724105  1.146584 

no significance found


t-Tests (Path length of all trials) between Strains


17-25 WT/dTg

mo25.WT=filter(mo25, Strain=="WT")
mo25.dTg=filter(mo25, Strain=="dTg")
t.test(mo25.WT$path.length,mo25.dTg$path.length)

    Welch Two Sample t-test

data:  mo25.WT$path.length and mo25.dTg$path.length
t = -7.4557, df = 286.47, p-value = 1.067e-12
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -333.6846 -194.2992
sample estimates:
mean of x mean of y 
 667.5763  931.5682 

17-25 WT/PS1dE9

mo25.WT=filter(mo25, Strain=="WT")
mo25.PS=filter(mo25, Strain=="PS1dE9")
t.test(mo25.WT$path.length,mo25.PS$path.length)

    Welch Two Sample t-test

data:  mo25.WT$path.length and mo25.PS$path.length
t = -2.4789, df = 228.85, p-value = 0.0139
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -183.21674  -20.94064
sample estimates:
mean of x mean of y 
 667.5763  769.6550 

17-25 WT/APPswe

mo25.WT=filter(mo25, Strain=="WT")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.WT$path.length,mo25.AP$path.length)

    Welch Two Sample t-test

data:  mo25.WT$path.length and mo25.AP$path.length
t = -3.6486, df = 268.81, p-value = 0.0003167
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -217.38161  -65.00338
sample estimates:
mean of x mean of y 
 667.5763  808.7688 

17-25 PS1dE9/APPswe

mo25.PS=filter(mo25, Strain=="PS1dE9")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.PS$path.length,mo25.AP$path.length)

    Welch Two Sample t-test

data:  mo25.PS$path.length and mo25.AP$path.length
t = -0.7493, df = 357.63, p-value = 0.4542
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -141.77175   63.54414
sample estimates:
mean of x mean of y 
 769.6550  808.7688 

17-25 dTg/PS1dE9

mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="PS1dE9")
t.test(mo25.dTg$path.length,mo25.PS$path.length)

    Welch Two Sample t-test

data:  mo25.dTg$path.length and mo25.PS$path.length
t = 3.2506, df = 343.79, p-value = 0.001266
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  63.94184 259.88464
sample estimates:
mean of x mean of y 
 931.5682  769.6550 

17-25 dTg/APPswe

mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.dTg$path.length,mo25.AP$path.length)

    Welch Two Sample t-test

data:  mo25.dTg$path.length and mo25.AP$path.length
t = 2.5701, df = 380.87, p-value = 0.01055
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  28.85462 216.74425
sample estimates:
mean of x mean of y 
 931.5682  808.7688